home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Grafik / Misc / ImageEnginer / ARexx / Batch / Blur_quick.ieb < prev    next >
Encoding:
Text File  |  1997-02-02  |  3.0 KB  |  123 lines

  1. /*
  2. ** $VER: Blur_quick.ieb 1.11, IE Arexx script
  3. ** Image Engineer Batch Processing script
  4. ** Copyright © by Patrik M Nydensten
  5. ** 25/1 1997 Stockholm/Sweden
  6. **
  7. ** Blurs image with simple scaling method.
  8. */
  9.  
  10. options results
  11. signal on error
  12.  
  13. parse arg input command
  14. input = upper(strip(input))
  15. address 'IMAGEENGINEER'
  16.  
  17. select  /* Required batch script commands */
  18.   when input = 'INFO' then    return get_info()
  19.   when input = 'CONFIG' then  return get_config(command)
  20.   when input = 'PROCESS' then return process_image(command)
  21.   otherwise do
  22.     'REQUEST' '"Failure in call to batch script!"' '" Quit "'
  23.     return '<ERROR>'
  24.   end
  25. end
  26.  
  27. exit 0
  28.  
  29. /* Required "Get_info" procedure  ------------------------------------ */
  30. /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files       */
  31.  
  32. get_info:
  33.   back = 'OK'
  34. return back
  35.  
  36. /* Required "Get_config" procedure  ---------------------------------- */
  37.  
  38. get_config:
  39.   parse arg '"'command'"'
  40.  
  41.   Blur=20
  42.  
  43.   if command ~= '' then parse var command Blur
  44.  
  45.   'IE_TO_FRONT'
  46.  
  47.   'FORM "Blur Quick" " OK | Cancel "',
  48.   ' INTEGER,"Blur amount",0,300,'Blur',SLIDER'
  49.  
  50.   parse var result ok Blur
  51.   if ok = 0 then return '<ERROR>'
  52.  
  53.   back = Blur
  54. return back
  55.  
  56. /* Required "Process_image" procedure  ------------------------------- */
  57.  
  58. process_image:
  59.   parse arg '"'src_image'"' '"'dst_image'"' '"'options'"'
  60.   parse var options Blur
  61.  
  62.   'OPEN' '"'src_image'"' '24'
  63.   if (RC ~= 0) then do
  64.     'IE_TO_FRONT'
  65.     'REQUEST' '"Failed to load image:' d2c(10)||src_image'"' '" OK "'
  66.     return '<ERROR>'
  67.   end
  68.   else LoadImage = Result
  69.  
  70.   if Blur ~= 0 then do
  71.     'PROJECT_INFO' LoadImage 'WIDTH'
  72.     IW = Result
  73.     'PROJECT_INFO' LoadImage 'HEIGHT'
  74.     IH = Result
  75.  
  76.     NewIW = trunc(IW/(Blur+1))
  77.     NewIH = trunc(IH/(Blur+1))
  78.  
  79.     if NewIW < 2 then NewIW = 2
  80.     if NewIH < 2 then NewIH = 2
  81.  
  82.     'SCALE' LoadImage NewIW NewIH 'BEST'
  83.     SmallImage = Result
  84.     'CLOSE' LoadImage
  85.  
  86.     'SCALE' SmallImage IW IH 'BEST'
  87.     OutputImage = Result
  88.     'CLOSE' SmallImage
  89.   end
  90.   else OutputImage = LoadImage
  91.  
  92.   if getclip('cfg_save_frmt')='' then setclip('cfg_save_frmt','ILBM CmpByteRun1')
  93.   'SAVE_DATA' OutputImage '"'dst_image'"' '"'getclip('cfg_save_frmt')'"'
  94.   if (RC ~= 0) then do
  95.     'IE_TO_FRONT'
  96.     'REQUEST' '"Failed to save image:' d2c(10)||dst_image'"' '" OK "'
  97.     return '<ERROR>'
  98.   end
  99.   'CLOSE' OutputImage
  100.  
  101.   back = 'OK'
  102. return back
  103.  
  104. /* Internal procedures  ---------------------------------------------- */
  105.  
  106. /*******************************************************************/
  107. /* This is where control goes when an error code is returned by IE */
  108. /* It puts up a message saying what happened and on which line     */
  109. /*******************************************************************/
  110. error:
  111. if RC=5 then do            /* Did the user just cancel us? */
  112.     IE_TO_FRONT
  113.     LAST_ERROR
  114.     'REQUEST "'||RESULT||'"'
  115. end
  116. else do
  117.     IE_TO_FRONT
  118.     LAST_ERROR
  119.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  120. end
  121.  
  122. return '<ERROR>'
  123.